<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-date"></i> 表单</el-breadcrumb-item>
                <el-breadcrumb-item>新增部门</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="form-box">
            <el-form ref="form" :model="form" label-width="80px">
                 <el-form-item label="部门名称">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="部门编码">
                    <el-input v-model="form.departmentCode"></el-input>
                </el-form-item>
              
               
              
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">提交</el-button>
                    <el-button>取消</el-button>
                </el-form-item>
            </el-form>
        </div>

    </div>
</template>

<script>
    export default {
        data: function(){
            return {
                form: {
                	departmentCode:'',
                    name: ''
                }
                
            }
        },
        created(){
            this.getData();
        },
        methods: {
	        onSubmit() {
		        var self = this;		       
		         if(!self.form.name){
		       		 this.$message.success('部门名称不可为空！');
		       		 return;
		        }
		          if(!self.form.departmentCode){
		       		 this.$message.success('部门编码不可为空！');
		       		 return;
		        }
		         
		        self.$axios({
			        method: 'post',
			        url: '../department/save',
			        handleAs:"json",
			        headers:{'Content-Type':'application/json'},
			        data: JSON.stringify(self.form)
			       
			    }).then(function (res) {
			      	self.sorcelist = res.data;		     
			    }).catch(function (err) {     
			    })
			     self.$message.success('添加成功！');
	    }
  	}
    }
</script>